
<!DOCTYPE html>
<html lang="en" class="no-js">

<head>

<meta charset="utf-8">
<title>用户注册界面</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Javascript -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/supersized.3.2.7.min.js"></script>
<script src="assets/js/supersized-init.js"></script>
<script src="assets/js/scripts.js"></script>
<!-- CSS -->
<link rel='stylesheet'
	href='http://fonts.googleapis.com/css?family=PT+Sans:400,700'>
<link rel="stylesheet" href="assets/css/reset.css">
<link rel="stylesheet" href="assets/css/supersized.css">
<link rel="stylesheet" href="assets/css/style.css">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

</head>

<body>
	<div class="page-container">
		<h1>注册页面</h1>
		<div class="register">
			<input type="text" name="username" class="username" placeholder="用户名">
			<input type="password" name="password" class="password"
				placeholder="密码"> <input type="text" name="userphone"
				class="userphone" placeholder="用户电话"> <input type="file"
				name="userphoto" class="userphoto">
			<!--    <input type="file" name="userphoto" class="username" placeholder="用户头像"> -->
			<button class="sum">注册</button>
			<div class="error">
				<span></span>
			</div>
		</div>
		<div class="connect">
			<p>通过以下方式联系我们:</p>
			<p>
				<a class="facebook" href=""></a> <a class="twitter" href=""></a>
			</p>
		</div>
	</div>


</body>
<script>
	$(document).ready(function(){
		$(".sum").click(function(){
				var username = $(".username").val();
				var password = $(".password").val();
				var userphone = $(".userphone").val();
			   	 var myform = new FormData();
		          myform.append("file",$(".userphoto")[0].files[0]);
		          myform.append("user.username",username);
		          myform.append("user.password",password);
		          myform.append("user.userphone",userphone);
		          $.ajax({
		              url: "register",
		              type: "POST",
		              data: myform,
		              saync: false,
		              contentType: false,
		              processData: false,
		              success:function(data){
		                  if(data.isSuccess){
		                      alert("注册成功!")
		                      window.location.href="login.html";
		                  }else{
		                      alert("注册失败!")
		                      window.location.href="register.html"
		                  }
		              },
		              error:function(data){
		                  alert("上传失败!")
		                  window.location.href="register.html"
		              }
		         });
		 });
});
		</script>
</html>

